#include <iostream>
#include "richterdatabase.h"
#include "mysqlpassword.h"
#include "exception.h"
#include <vector>

using namespace std;

int main()
{
    SHA1Generator sha1;
    sha1.start();
    sha1.addString("alma");
    SHA1Generator::Hash hash = sha1.end();
    cout << SHA1Generator::convertHashToString(hash) << endl;

    // proba
    try {
        RichterDatabase & dbase = RichterDatabase::instance();
        dbase.connect("localhost", "root", MYSQL_PASSWORD);
        //RichterDatabase::instance().addPlace("garazs");
        vector<Places> places;
        places = dbase.getPlaces();

        cout << "Helyek szama: " << places.size() << endl;
        int i;
        for (i = 0; i < places.size(); i++) {
            cout << "ID: " << places[i].id << endl;
            cout << "DESC: " << places[i].description << endl;
            cout << "---------------" << endl;
        }

        dbase.removePlace(4);

    } catch ( const Exception & ex ) {
        cout << ex.getErrorMessage() << endl;
    } catch (char hiba) {
        cout << "hibakod: " << hiba << endl;

    } catch (int hiba) {
        cout << "hibakod: " << hiba << endl;
    } catch (...) {
        cout << "Ismeretlen hiba" << endl;
    }


    // haliho
    return 0;
}

